package com.javaPro.myProject.modules.homework.service.impl;

import com.javaPro.myProject.modules.homework.entity.Homework;
import com.javaPro.myProject.modules.homework.dao.HomeworkDao;
import com.javaPro.myProject.modules.homework.service.HomeworkService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * 到访体验表(Homework)表服务实现类

 */
@Service("homeworkService")
public class HomeworkServiceImpl implements HomeworkService {
    @Resource
    private HomeworkDao homeworkDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Homework queryById(Integer id) {
        return this.homeworkDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param homework 筛选条件

     * @return 查询结果
     */
    @Override
    public List<Homework> queryByPage(Homework homework) {

        return this.homeworkDao.queryAllByLimit(homework);
    }
    @Override
    public List<Homework> queryByPageT(Homework homework) {

        return this.homeworkDao.queryAllByLimitT(homework);
    }

    /**
     * 新增数据
     *
     * @param homework 实例对象
     * @return 实例对象
     */
    @Override
    public Homework insert(Homework homework) {
        this.homeworkDao.insert(homework);
        return homework;
    }

    /**
     * 修改数据
     *
     * @param homework 实例对象
     * @return 实例对象
     */
    @Override
    public Homework update(Homework homework) {
        this.homeworkDao.update(homework);
        return this.queryById(homework.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public int deleteById(Integer id) {
        return this.homeworkDao.deleteById(id);
    }
}
